home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / dsp / dspgroup / m56000_2.arc / SMALLFFT.ASM < prev   
Encoding:
Assembly Source File  |  1986-01-20  |  2.4 KB  |  91 lines

  1.         page    132,66,2,2
  2. smallfft     macro   points,passes,data,twiddle
  3. ;
  4. ; Radix 2 Decimation in Time In-Place Fast Fourier Transform Routine
  5. ;
  6. ;    Complex input and output data
  7. ;        Real data in X memory
  8. ;        Imaginary data in Y memory
  9. ;    Normally ordered input data
  10. ;    Bit reversed output data
  11. ;    Twiddle factors lookup table
  12. ;        Cosine value in X memory
  13. ;        -Sine value in Y memory
  14. ;
  15. ; Macro Call - smallfft  points,passes,data,twiddle
  16. ;
  17. ;    points     number of points (4-32768, power of 2)
  18. ;    passes     number of fft passes (log2 points)
  19. ;    data       start of data buffer
  20. ;    twiddle    start of sine/cosine table
  21. ;
  22. ; Alters Data ALU Registers
  23. ;    x1    x0    y1    y0
  24. ;    a2    a1    a0    a
  25. ;    b2    b1    b0    b
  26. ;
  27. ; Alters Address Registers
  28. ;    r0    n0    m0
  29. ;    r1    n1    m1
  30. ;        n2
  31. ;
  32. ;    r4    n4    m4
  33. ;    r5    n5    m5
  34. ;    r6    n6    m6
  35. ;
  36. ; Alters Program Control Registers
  37. ;    pc    sr
  38. ;
  39. ; Uses 6 locations on System Stack
  40. ;
  41. ; Authors - Kevin Kloker and Garth Hillman
  42. ; Latest Revision - Jan.  20, 1986
  43. ;
  44.     page
  45.     move     #points,n0    ;initialize butterflies per group
  46.     move    #1,n2        ;initialize groups per pass
  47.     move    #points/4,n6    ;initialize twiddle offset
  48.     move    #-1,m0        ;initialize address modifiers
  49.     move    m0,m1        ;for linear addressing
  50.     move    m0,m4
  51.     move    m0,m5
  52.     move    #0,m6        ;initialize twiddle factor address modifier
  53.                 ;for reverse carry (bit reversed) addressing
  54. ;
  55. ; Perform all FFT passes with triple nested DO loop
  56. ;
  57.     do    #passes,_end_pass
  58.     move    n0,a1        ;divide butterflies per group by two
  59.     lsr    a    #data,r0    ;and initialize A input pointer
  60.     move    a1,n0        ;update butterflies per group
  61.     move    r0,r4        ;initialize A output pointer
  62.     lua    (r0)+n0,r1    ;initialize B input pointer
  63.     lua    (r1)-,r5    ;initialize B output pointer
  64.     move    #twiddle,r6    ;initialize twiddle factor pointer
  65.     move    n0,n1        ;initialize pointer offsets
  66.     move    n0,n4
  67.     move    n0,n5
  68.  
  69.     do    n2,_end_grp
  70.     move    x:(r1),x1    y:(r6),y0    ;lookup -sine value
  71.     move    x:(r5),a    y:(r0),b    ;dummy load of a
  72.     move    x:(r6)+n6,x0        ;lookup cosine value
  73.  
  74.  
  75.     do    n0,_end_bfy
  76.     mac    x1,y0,b                y:(r1)+,y1    ;Radix 2 DIT butterfly kernel
  77.     macr    x0,y1,b        a,x:(r5)+    y:(r0),a    ;with constant twiddle factor
  78.     subl    b,a        x:(r0),b    b,y:(r4)
  79.     mac    x1,x0,b        x:(r0)+,a    a,y:(r5)
  80.     macr    -y1,y0,b    x:(r1),x1
  81.     subl    b,a        b,x:(r4)+    y:(r0),b
  82. _end_bfy
  83.     move    a,x:(r5)+n5    y:(r1)+n1,y1    ;dummy load of x1 and y1
  84.     move    x:(r0)+n0,x1    y:(r4)+n4,y1
  85. _end_grp
  86.     move    n2,a1
  87.     lsl    a        ;multiply groups per pass by two
  88.     move    a1,n2        ;update groups per pass
  89. _end_pass
  90.     endm
  91.